function return_module(data) {
    ajaxLoaderClose();
    if(typeof data.result_error == "undefined" || data.result_error==false){
        fdialog(null,data.messageAction,'success', data.locationAction);
        $('#list-ccontrataciones tbody').prepend('<tr><td>' + data.titulo + '</td><td>' + data.denominacion + '</td><td><a href="' + HOST_PATHS + 'inventory/edit/' + data.id + '">Editar</a> <a href="' + HOST_PATHS + 'inventory/lock/' + data.id + '">Desactivar</a></td></tr>');
        tableContent();   
    }else{
        fdialog(null,data.result_error,'message');
    }
};
$(document).ready(function() {
    $(".state").on({
        click: function(){
            pointer=this;
            var id=$(pointer).attr('ref');
            ajaxLoader();
            if($(pointer).hasClass('disable')){
                url=HOST_PATHS+'ccontrataciones/disable/'+id;
                text='Activar';
                addClass='enable';
                removeClass='disable';
            }else if($(pointer).hasClass('enable')){
                url=HOST_PATHS+'ccontrataciones/enable/'+id;
                text='Desactivar';
                addClass='disable';
                removeClass='enable';
            }
            $.ajax({ 
                type: "GET",
                dataType: 'json',
                url: url,
                success: function(data){
                    ajaxLoaderClose();
                    if(typeof data.result_error == "undefined" || data.result_error==false){
                        $(pointer).text(text);
                        $(pointer).removeClass(removeClass);
                        $(pointer).addClass(addClass);
                        fdialog(null,data.messageAction,'success');
                        tableContent();
                    }else{
                        fdialog(null,data.result_error,'message');
                    }
                }
            });
        }
    });
    var count = 0;
    $(".municipio").live({
        click: function(){
            pointer=this;
            var id=$(pointer).attr('ref');
            if($(pointer).hasClass('close')){
                ajaxLoader();
                url=HOST_PATHS+'carga/parroquia/'+id;
                addClass='open';
                removeClass='close';
                $.ajax({ 
                    type: "GET",
                    dataType: 'html',
                    url: url,
                    success: function(data){
                        ajaxLoaderClose();
                        $(pointer.parentNode.parentNode).after('<tr><td colspan="8">'+data+'</td></tr>');
                    }
                });
            }else{
                url=HOST_PATHS+'ccontrataciones/enable/'+id;
                addClass='close';
                removeClass='open';
                $(pointer.parentNode.parentNode.nextSibling).remove();
            }
            $(pointer).removeClass(removeClass);
            $(pointer).addClass(addClass);
        }
    });
    $(".parroquia").live({
        click: function(){
            pointer=this;
            var id=$(pointer).attr('ref');
            if($(pointer).hasClass('close')){
                ajaxLoader();
                url=HOST_PATHS+'carga/centro/'+id;
                addClass='open';
                removeClass='close';
                $.ajax({ 
                    type: "GET",
                    dataType: 'html',
                    url: url,
                    success: function(data){
                        ajaxLoaderClose();
                        $(pointer.parentNode.parentNode).after('<tr><td colspan="8">'+data+'</td></tr>');
                    }
                });
            }else{
                url=HOST_PATHS+'ccontrataciones/enable/'+id;
                addClass='close';
                removeClass='open';
                $(pointer.parentNode.parentNode.nextSibling).remove();
            }
            $(pointer).removeClass(removeClass);
            $(pointer).addClass(addClass);
        }
    });
    $(".centro").live({
        click: function(){
            pointer=this;
            var id=$(pointer).attr('ref');
            if($(pointer).hasClass('close')){
                ajaxLoader();
                url=HOST_PATHS+'carga/reporteCentro/'+id;
                addClass='open';
                removeClass='close';
                $.ajax({ 
                    type: "GET",
                    dataType: 'html',
                    url: url,
                    success: function(data){
                        ajaxLoaderClose();
                        $(pointer.parentNode.parentNode).after('<tr><td colspan="8">'+data+'</td></tr>');
                    }
                });
            }else{
                url=HOST_PATHS+'ccontrataciones/enable/'+id;
                addClass='close';
                removeClass='open';
                $(pointer.parentNode.parentNode.nextSibling).remove();
            }
            $(pointer).removeClass(removeClass);
            $(pointer).addClass(addClass);
        }
    });
});
$('#carga_reporte_centro').live({
    submit: function(event){
        ajaxLoader();
        pointer=this;
        var url = $(pointer).attr('action');
        var data = $(pointer).serialize();
        pointer.reset();
        field=convertDataSerializeToArray(data);
        event.preventDefault();
        $.ajax({ 
            type: "POST",
            url: url,
            dataType: 'json',
            data: data,
            success: function(data){
                ajaxLoaderClose();
                if(typeof data.result_error == "undefined" || data.result_error==false){
                    fdialog(null,data.messageAction,'success');
                    $(pointer).find('.listMethodController').append('<dt><strong>'+data.name+'</strong> <div ref="' + data.id + '" class="styleLink removeMethod">X</div></dt>');
                }else{
                    fdialog(null,data.result_error,'message');
                }
                $(pointer.parentNode).remove();
            }
        });
    }
});